<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use cmf\controller\HomeBaseController;
use app\portal\model\PortalPostModel as PostModel;
class IndexController extends HomeBaseController
{
    public function index()
    {
        $uri = $_SERVER['REQUEST_URI'];
        $protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ?"https://": "http://";
        $url = str_replace('&','&',htmlspecialchars_decode($protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']));
        $new=PostModel::select($url);
        $newurl = implode(",", $new);

        // $arr = array(1,2,3,4);
        // $num=array();
        // foreach($arr as $key=>$va)
        // {
        //     foreach($arr as $val)
        //     {
        //         if($va+$val==3){
        //            array_push($num,$key);
        //         }
        //     }
        // }
        // $n=json_encode($num);

        // $this->assign('id',$id);
        // $this->assign('page',$pageclass);
        // $this->assign('url',$urlaa);       
        // $this->assign('num',$n);
        echo "<script>location.href='$newurl'</script>";     
        // header("Location: $newurl");
        // return $this->fetch(':index');
    }
    public function index1()
    {
        $uri = $_SERVER['REQUEST_URI'];
        $protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ?"https://": "http://";
        $url = str_replace('&','&',htmlspecialchars_decode($protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']));
        $new=PostModel::select($url);
        $newurl = implode(",", $new);
        echo "<script>location.href='$newurl'</script>";     
    }
    
}
